import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

if __name__ == '__main__':
    url = "https://www.taobao.com"

    executable_path = "../drivers/chromedriver.exe"

    service = Service(executable_path=executable_path)
    browser = webdriver.Chrome(service=service)

    browser.get(url=url)
    # 睡眠 10 秒，然后继续

    # 通过 id 属性查找网页中的元素
    element = browser.find_element(by=By.ID, value="q")
    print(element)

    # 通过 CSS 选择器查找网页中的元素
    element = browser.find_element(by=By.CSS_SELECTOR, value="#q")
    print(element)

    # 通过 XPath 进行查找
    element = browser.find_element(by=By.XPATH, value="//*[@id='q']")
    print(element)
    browser.quit()
